    //
//  NewsDetailViewController.m
//  VNExpressRSS
//
//  Created by Vinh Huynh on 8/26/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "NewsDetailViewController.h"
#import "News.h"


@implementation NewsDetailViewController

@synthesize titleTextView;
@synthesize descTextView;
@synthesize news;
@synthesize thumbnail;
@synthesize pubDateLabel;
@synthesize tabBar;

-(IBAction) backButtonPressed{
	[self.navigationController popViewControllerAnimated:YES];
} 

-(id) getNewsDetail:(News *)aNews{
	news = aNews;
	if (news.thumbnailLink != @"") {
		thumbnail.image = news.thumbnail;
	}
	else {
		thumbnail.image = [UIImage imageNamed:@"nophoto.png"]; 
	}
	[titleTextView setFont:[UIFont systemFontOfSize:17]];
	[titleTextView setText:news.title];
	[descTextView setFont:[UIFont systemFontOfSize:14]];
	[descTextView setText:news.description];
	[pubDateLabel setText:news.pubDate];
	return self;	
}

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
	if (buttonIndex == 0) {
		[[UIApplication sharedApplication] openURL:[NSURL URLWithString:news.link]];
	}
}

-(IBAction) openOnWeb{
	UIActionSheet *actionSheep = [[UIActionSheet alloc] initWithTitle:@"Bạn có muốn đọc tin trên Web?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Open" otherButtonTitles:nil];
	actionSheep.actionSheetStyle = UIActionSheetStyleDefault;
	[actionSheep showFromTabBar:tabBar];
	[actionSheep release];
}

- (void)viewDidLoad {
	self.news = [[News alloc] init];
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}

- (void)dealloc {
    [super dealloc];
	self.tabBar = nil;
	self.pubDateLabel = nil;
	self.news = nil;
	self.titleTextView = nil;
	self.thumbnail = nil;
	self.descTextView = nil;
}

@end
